/*
  @Author: Vayne
  @describe:蓝牙打印方法
 */
import tools from './bluetoothPri'
export default function (data = {}, printTimes = '1') {
  let { NAME, SX, TIME, SKU } = data
  let printInfo = []
  //1.定义纸张大小
  printInfo.push(
    tools.pageSetup({
      pageWidth: '640',
      pageHeight: '400',
      printTimes: printTimes, //打印多少份
    })
  )
  //2.定义打印内容
  //静态文字
  printInfo.push(
    tools.drawText({
      fontTypeName: 'Cn1',
      fontSizeName: 'C0',
      x: 150,
      y: 50,
      bold: 1,
      data: '中集创见有限公司',
      vertical: 1,
      setMagSizeW: 0,
      setMagSizeH: 0,
    })
  ) // 标题

  printInfo.push(
    tools.drawText({
      fontTypeName: 'Cn1',
      fontSizeName: 'C0',
      x: 100,
      y: 100,
      bold: 0,
      data: `收料人:${NAME}`,
      vertical: 1,
      setMagSizeW: 0,
      setMagSizeH: 0,
    })
  ) // 收料人
  printInfo.push(
    tools.drawText({
      fontTypeName: 'Cn1',
      fontSizeName: 'C0',
      x: 100,
      y: 150,
      bold: 0,
      data: `来料属性:${SX}`,
      vertical: 1,
      setMagSizeW: 0,
      setMagSizeH: 0,
    })
  ) // 来料属性

  printInfo.push(
    tools.drawText({
      fontTypeName: 'Cn1',
      fontSizeName: 'C0',
      x: 100,
      y: 200,
      bold: 0,
      data: `来料时间:${TIME}`,
      vertical: 1,
      setMagSizeW: 0,
      setMagSizeH: 0,
    })
  ) // 来料时间
  printInfo.push(
    tools.drawBarCode({
      type: 128,
      width: 0,
      height: 70,
      x: 300,
      y: 250,
      data: SKU,
      showText: 1,
      vertical: 0,
    })
  ) // 物料编码(条形码)
  printInfo.push(
    tools.drawQRCode({
      x: 100,
      y: 300,
      M: 1,
      U: 4,
      data: SKU,
      vertical: 0,
    })
  ) //二维码条码
  printInfo = tools.doPrint({
    printCode: printInfo,
    addFrom: 1,
  })

  return printInfo
}
